#include <vector>
#include "string.hpp"
#include <iostream>

#define DEFAULT_GITHUB_URL "https://github.com/"

using namespace wgets;

int main(int argc, char **argv) {

    std::vector<string> args(argc);
    for (int i = 0; i < argc; i++) {
        args[i] = argv[i];
    }

    string param;
    if (args.size() > 1) {
        if (args[1].startsWith(DEFAULT_GITHUB_URL)) {
            args[1] = "https://mirror.ghproxy.com/" + args[1];
        }
        param = args[1];
        // 打印 param
        std::cout << "github url: " << param << std::endl;
    }

    // string command = "wget " + args[1];
    string command = "aria2c " + param;
    const char *command_ = command.c_str();
    auto err = system(command_);
    if (err != 0) {
        return err;
    }
    return 0;
}
